import Vue from 'vue'
import Router from 'vue-router'
import Home from '@/components/page/Home'
import Journal from '@/components/page/Journal'
import TaskList from '@/components/TaskList'
import Task from '@/components/page/Task'
import Login from '@/components/page/Login'
import Day from '@/components/Day'
import Week from '@/components/Week'
import Year from '@/components/Year'
import Month from '@/components/Month'
import SignUp from '@/components/page/SignUp'
import Feedback from '@/components/page/Feedback'

Vue.use(Router)

export default new Router({
  routes: [
    {
      path: '/',
      name: 'home',
      component: Home,
      meta: {
        requiresAuth: true
      }
    },
    {
      path: '/home',
      name: 'home',
      component: Home,
      meta: {
        requiresAuth: true
      },
      children: [
        {
          path: '/home/taskList/:type',
          name: 'taskList',
          component: TaskList,
          meta: {
            requiresAuth: true
          }
        }
      ]
    },
    {
      path: '/journal',
      name: 'journal',
      component: Journal,
      meta: {
        requiresAuth: true
      },
      children: [
        {
          path: '/journal/day',
          name: 'day',
          component: Day,
          meta: {
            requiresAuth: true
          }
        },
        {
          path: '/journal/week',
          name: 'week',
          component: Week,
          meta: {
            requiresAuth: true
          }
        },
        {
          path: '/journal/month',
          name: 'month',
          component: Month,
          meta: {
            requiresAuth: true
          }
        },
        {
          path: '/journal/year',
          name: 'year',
          component: Year,
          meta: {
            requiresAuth: true
          }
        }
      ]
    },
    {
      path: '/taskList',
      name: 'taskList',
      component: TaskList,
      meta: {
        requiresAuth: true
      }
    },
    {
      path: '/task/:id?', // 问号使得参数可选
      name: 'task',
      component: Task,
      meta: {
        requiresAuth: true
      }
    },
    {
      path: '/login',
      name: 'login',
      component: Login,
      meta: {
        requiresAuth: false // 不需要登陆就可以访问
      }
    },
    {
      path: '/signUp',
      name: 'signUp',
      component: SignUp,
      meta: {
        requiresAuth: true
      }
    },
    {
      path: '/feedback',
      name: 'feedback',
      component: Feedback,
      meta: {
        requiresAuth: true
      }
    }
  ]
})
